<template>
  <div class="login-wrap">
      <div class="title">全球医疗资源尽在仁灏优医！</div>
      <div class="input-item box box-align-center">
          <div class="icon"></div>
          <input v-model="mobile" type="text" placeholder="请输入手机号/邮箱">
      </div>
      <div class="input-item box box-align-center">
          <div class="icon"></div>
          <input v-model="pwd" type="password" :max='18' placeholder="请输入密码">
      </div>
      <div @click="login" class="btn">登录</div>
      <div class="btn-list box box-align-center box-pack-between">
          <div class="forget" @click="linkTo('forget')">忘记密码</div>
          <div class="forget" @click="linkTo('register')">新用户注册</div>
      </div>
  </div>
</template>

<script>
let CONSTANT = require('../../../wechat/static/constant/constant.js'),
    common = require("../../../wechat/static/common/common.js"),
    wsService = require("../../../wechat/static/common/wechat-jsdk.js");
export default {
  components: {
      
  },
  data () {
    return {
        mobile:'',
        pwd:'',
        sessionId:''
    }
  },
  mounted(){
   
  },
  methods:{
     linkTo(link){
        this.$router.push(link)
        
      },
      login(){
        if (!this.mobile) {
            this.$vux.toast.show({
                text: '账号不能为空',
                type:'cancel'
            })
            return;
        }
        if (!this.pwd) {
            this.$vux.toast.show({
                text: '密码不能为空',
                type:'cancel'
            })
            return;
        }
        let  url = CONSTANT.URL.LOGIN.LOGIN,
            param = {
                mobile:this.mobile,
                pwd:this.pwd,
                dev:'y'
            }
        common.requestAjax(url,{},param,(res)=>{
            if(res.status == 200){
                let sessionId = res.data.bussData.sessionId;
                common.setCookie("sessionId", sessionId);
                this.$vux.toast.show({
                    text: res.msg
                })
                let  url = CONSTANT.URL.DOCTOR.BINDWEIXIN,
                    param = {id:common.getCookie("id")}
                common.requestAjax(url,{},param,(res)=>{
                    if(res.status == 200){
                    }else{

                    }
                })
                this.$router.replace('/')
            }else{
              this.$vux.toast.show({
                    text:res.msg,
                    type:'cancel'
                })
            }
        })         
      }
  }
}
</script>

<style lang="scss">
    .login-wrap{
        width: 100%;
        height: 12.1rem;
        background-image: url(../../images/login.png);
        background-size:100%;
        .title{
            font-size: .3rem;
            text-align: center;
            color: #666;
            padding-top: 3.48rem;
        }
        .input-item{
            width: 4.5rem;
            height: .7rem;
            border-bottom: 1px solid #fff;
            margin: 2.2rem auto 0;
            &:nth-child(3){
                margin-top: .8rem;
            }
            .icon{
                width: .18rem;
                height: .32rem;
                background-image: url(../../images/phone.png);
                background-size:100%;       
            }
            input{
                border: 0px;     
                height: .7rem;
                margin-left: .12rem;
                background: none;
                font-size: .3rem;
                color: #CAEAFF;
                &:focus{
                    outline: 0;
                }
                &::-webkit-input-placeholder{
                    color:#CAEAFF;                 
                } 
            }
            &:nth-child(3){
                .icon{
                    width: .16rem;
                    height: .3rem;
                    background-image: url(../../images/password.png);    
                } 
            }
        }
        .btn{
            width: 4.94rem;
            height: .88rem;
            line-height: .88rem;
            text-align: center;
            margin: 1.46rem auto .3rem;
            background-color: #fff;
            color: #0063AE;
            font-size: .34rem;
            border-radius: 4px;
            -webkit-border-radius: 4px;
        }
        .btn-list{
            font-size: .3rem;
            color: #CAEAFF;
            width: 4.94rem;
            margin: 0 auto;
        }
    }
</style>
